package com.czg.jsonschema2lombokpojo.annotator;

import com.czg.jsonschema2lombokpojo.config.GenerationConfig;
import com.fasterxml.jackson.databind.JsonNode;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JEnumConstant;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMethod;

/**
 * Annotator接口的默认实现，可以更容易地插入不同的Annotator实现。
 * <p>
 * 需要生成配置的注解器应该添加一个带有{@link GenerationConfig}参数的构造器。不需要配置的注解器只需要添加一个默认构造函数。
 */
public abstract class AbstractAnnotator implements Annotator {

    private GenerationConfig generationConfig;

    public AbstractAnnotator() {
    }

    public AbstractAnnotator(GenerationConfig generationConfig) {
        this.generationConfig = generationConfig;
    }

    /**
     * 生成pojo类，需要序列化注解
     * @param clazz
     *            生成pojo类，需要序列化注解
     * @param schema
     *            与此相关的对象schema
     */
    @Override
    public void typeInfo(JDefinedClass clazz, JsonNode schema, boolean isEnum) {

    }

    @Override
    public void propertyInclusion(JDefinedClass clazz, JsonNode schema) {
    }

    @Override
    public void propertyField(JFieldVar field, JDefinedClass clazz,
            String propertyName, JsonNode propertyNode) {
    }


    @Override
    public void anyGetter(JMethod getter, JDefinedClass clazz) {
    }

    @Override
    public void anySetter(JMethod setter, JDefinedClass clazz) {
    }

    @Override
    public void enumCreatorMethod(JDefinedClass _enum, JMethod creatorMethod) {
    }

    @Override
    public void enumValueMethod(JDefinedClass _enum, JMethod valueMethod) {
    }

    @Override
    public void enumConstant(JDefinedClass _enum, JEnumConstant constant, String value) {
    }

    @Override
    public boolean isAdditionalPropertiesSupported() {
        return true;
    }

    @Override
    public boolean isPolymorphicDeserializationSupported(JsonNode node) {
        return false;
    }

    public GenerationConfig getGenerationConfig() {
        return generationConfig;
    }

    @Override
    public void dateField(JFieldVar field, JDefinedClass clazz, JsonNode node) {
    }

    @Override
    public void timeField(JFieldVar field, JDefinedClass clazz, JsonNode node) {
    }

    @Override
    public void dateTimeField(JFieldVar field, JDefinedClass clazz, JsonNode node) {
    }
}
